﻿-- Author      : Yottabyte
-- Create Date : 2/14/2011 10:55:36 PM

--Slash Command--
SLASH_GUILDKICKER1, SLASH_GUILDKICKER2, SLASH_GUILDKICKER3 = '/gk', '/gkicker', '/guildkicker';
function SlashCmdList.GUILDKICKER(msg, editbox)
 GKPermissionsCheck();
end

--Load Functions--
function GKLoader()
GKInactiveEditBox:SetScript("OnEscapePressed", function(self) GuildKicker:Hide() end)
GKInactiveEditBox:SetScript("OnTabPressed", function(self) GKLowLevelEditBox:SetFocus() end)
GKLowLevelEditBox:SetScript("OnEscapePressed", function(self) GuildKicker:Hide() end)
GKLowLevelEditBox:SetScript("OnTabPressed", function(self) GKInactiveEditBox:SetFocus() end)
print('Guild Kicker is loaded and fully operational! Use "/gk" "/gkicker" or "/guildkicker" to access the menu. A button is also available on the Who Frame.')
end

function GKPermissionsCheck()
if IsInGuild()==1 and CanGuildRemove()==1 then
GuildKicker:Show()
GKFindRank()
GKSetRankDisplay()
GKSetRankKickable()
else
GuildKicker:Hide()
print('ERROR! Guild Kicker was UNLOADED because you are not in a guild, or you do not have Guild Remove permission!')
end
end

function GKSetRankDisplay()
if GuildControlGetNumRanks()==10 then
Rank2Font:SetText(GuildControlGetRankName(2))
Rank3Font:SetText(GuildControlGetRankName(3))
Rank4Font:SetText(GuildControlGetRankName(4))
Rank5Font:SetText(GuildControlGetRankName(5))
Rank6Font:SetText(GuildControlGetRankName(6))
Rank7Font:SetText(GuildControlGetRankName(7))
Rank8Font:SetText(GuildControlGetRankName(8))
Rank9Font:SetText(GuildControlGetRankName(9))
Rank10Font:SetText(GuildControlGetRankName(10))
elseif GuildControlGetNumRanks()==9 then
Rank2Font:SetText(GuildControlGetRankName(2))
Rank3Font:SetText(GuildControlGetRankName(3))
Rank4Font:SetText(GuildControlGetRankName(4))
Rank5Font:SetText(GuildControlGetRankName(5))
Rank6Font:SetText(GuildControlGetRankName(6))
Rank7Font:SetText(GuildControlGetRankName(7))
Rank8Font:SetText(GuildControlGetRankName(8))
Rank9Font:SetText(GuildControlGetRankName(9))
Rank10Font:Hide()
GKRank10Check:Hide()
elseif GuildControlGetNumRanks()==8 then
Rank2Font:SetText(GuildControlGetRankName(2))
Rank3Font:SetText(GuildControlGetRankName(3))
Rank4Font:SetText(GuildControlGetRankName(4))
Rank5Font:SetText(GuildControlGetRankName(5))
Rank6Font:SetText(GuildControlGetRankName(6))
Rank7Font:SetText(GuildControlGetRankName(7))
Rank8Font:SetText(GuildControlGetRankName(8))
Rank9Font:Hide()
GKRank9Check:Hide()
Rank10Font:Hide()
GKRank10Check:Hide()
elseif GuildControlGetNumRanks()==7 then
Rank2Font:SetText(GuildControlGetRankName(2))
Rank3Font:SetText(GuildControlGetRankName(3))
Rank4Font:SetText(GuildControlGetRankName(4))
Rank5Font:SetText(GuildControlGetRankName(5))
Rank6Font:SetText(GuildControlGetRankName(6))
Rank7Font:SetText(GuildControlGetRankName(7))
Rank8Font:Hide()
GKRank8Check:Hide()
Rank9Font:Hide()
GKRank9Check:Hide()
Rank10Font:Hide()
GKRank10Check:Hide()
elseif GuildControlGetNumRanks()==6 then
Rank2Font:SetText(GuildControlGetRankName(2))
Rank3Font:SetText(GuildControlGetRankName(3))
Rank4Font:SetText(GuildControlGetRankName(4))
Rank5Font:SetText(GuildControlGetRankName(5))
Rank6Font:SetText(GuildControlGetRankName(6))
Rank7Font:Hide()
GKRank7Check:Hide()
Rank8Font:Hide()
GKRank8Check:Hide()
Rank9Font:Hide()
GKRank9Check:Hide()
Rank10Font:Hide()
GKRank10Check:Hide()
elseif GuildControlGetNumRanks()==5 then
Rank2Font:SetText(GuildControlGetRankName(2))
Rank3Font:SetText(GuildControlGetRankName(3))
Rank4Font:SetText(GuildControlGetRankName(4))
Rank5Font:SetText(GuildControlGetRankName(5))
Rank6Font:Hide()
GKRank6Check:Hide()
Rank7Font:Hide()
GKRank7Check:Hide()
Rank8Font:Hide()
GKRank8Check:Hide()
Rank9Font:Hide()
GKRank9Check:Hide()
Rank10Font:Hide()
GKRank10Check:Hide()
elseif GuildControlGetNumRanks()==4 then
Rank2Font:SetText(GuildControlGetRankName(2))
Rank3Font:SetText(GuildControlGetRankName(3))
Rank4Font:SetText(GuildControlGetRankName(4))
Rank5Font:Hide()
GKRank5Check:Hide()
Rank6Font:Hide()
GKRank6Check:Hide()
Rank7Font:Hide()
GKRank7Check:Hide()
Rank8Font:Hide()
GKRank8Check:Hide()
Rank9Font:Hide()
GKRank9Check:Hide()
Rank10Font:Hide()
GKRank10Check:Hide()
elseif GuildControlGetNumRanks()==3 then
Rank2Font:SetText(GuildControlGetRankName(2))
Rank3Font:SetText(GuildControlGetRankName(3))
Rank4Font:Hide()
GKRank4Check:Hide()
Rank5Font:Hide()
GKRank5Check:Hide()
Rank6Font:Hide()
GKRank6Check:Hide()
Rank7Font:Hide()
GKRank7Check:Hide()
Rank8Font:Hide()
GKRank8Check:Hide()
Rank9Font:Hide()
GKRank9Check:Hide()
Rank10Font:Hide()
GKRank10Check:Hide()
elseif GuildControlGetNumRanks()==2 then
Rank2Font:SetText(GuildControlGetRankName(2))
Rank3FontHide()
GKRank3Check:Hide()
Rank4Font:Hide()
GKRank4Check:Hide()
Rank5Font:Hide()
GKRank5Check:Hide()
Rank6Font:Hide()
GKRank6Check:Hide()
Rank7Font:Hide()
GKRank7Check:Hide()
Rank8Font:Hide()
GKRank8Check:Hide()
Rank9Font:Hide()
GKRank9Check:Hide()
Rank10Font:Hide()
GKRank10Check:Hide()
else
Rank2Font:Hide()
GKRank2Check:Hide()
Rank3FontHide()
GKRank3Check:Hide()
Rank4Font:Hide()
GKRank4Check:Hide()
Rank5Font:Hide()
GKRank5Check:Hide()
Rank6Font:Hide()
GKRank6Check:Hide()
Rank7Font:Hide()
GKRank7Check:Hide()
Rank8Font:Hide()
GKRank8Check:Hide()
Rank9Font:Hide()
GKRank9Check:Hide()
Rank10Font:Hide()
GKRank10Check:Hide()
end
end

function GKFindRank()
for i=1,GetNumGuildMembers(true) do local name,rank,rankindex = GetGuildRosterInfo(i);
local playerName = UnitName("player")
if name==playerName then
GKSelfRank=rank
end
end
end

function GKSetRankKickable()
if GKSelfRank==GuildControlGetRankName(1) then

elseif GKSelfRank==GuildControlGetRankName(2) then
GKRank2Check:SetChecked(1)
GKRank2Check:Disable()
GKRank3Check:SetChecked(0)
GKRank3Check:Enable()
GKRank4Check:SetChecked(0)
GKRank4Check:Enable()
GKRank5Check:SetChecked(0)
GKRank5Check:Enable()
GKRank6Check:SetChecked(0)
GKRank6Check:Enable()
GKRank7Check:SetChecked(0)
GKRank7Check:Enable()
GKRank8Check:SetChecked(0)
GKRank8Check:Enable()
GKRank9Check:SetChecked(0)
GKRank9Check:Enable()
GKRank10Check:SetChecked(0)
GKRank10Check:Enable()
elseif GKSelfRank==GuildControlGetRankName(3) then
GKRank2Check:SetChecked(1)
GKRank2Check:Disable()
GKRank3Check:SetChecked(1)
GKRank3Check:Disable()
GKRank4Check:SetChecked(0)
GKRank4Check:Enable()
GKRank5Check:SetChecked(0)
GKRank5Check:Enable()
GKRank6Check:SetChecked(0)
GKRank6Check:Enable()
GKRank7Check:SetChecked(0)
GKRank7Check:Enable()
GKRank8Check:SetChecked(0)
GKRank8Check:Enable()
GKRank9Check:SetChecked(0)
GKRank9Check:Enable()
GKRank10Check:SetChecked(0)
GKRank10Check:Enable()
elseif GKSelfRank==GuildControlGetRankName(4) then
GKRank2Check:SetChecked(1)
GKRank2Check:Disable()
GKRank3Check:SetChecked(1)
GKRank3Check:Disable()
GKRank4Check:SetChecked(1)
GKRank4Check:Disable()
GKRank5Check:SetChecked(0)
GKRank5Check:Enable()
GKRank6Check:SetChecked(0)
GKRank6Check:Enable()
GKRank7Check:SetChecked(0)
GKRank7Check:Enable()
GKRank8Check:SetChecked(0)
GKRank8Check:Enable()
GKRank9Check:SetChecked(0)
GKRank9Check:Enable()
GKRank10Check:SetChecked(0)
GKRank10Check:Enable()
elseif GKSelfRank==GuildControlGetRankName(5) then
GKRank2Check:SetChecked(1)
GKRank2Check:Disable()
GKRank3Check:SetChecked(1)
GKRank3Check:Disable()
GKRank4Check:SetChecked(1)
GKRank4Check:Disable()
GKRank5Check:SetChecked(1)
GKRank5Check:Disable()
GKRank6Check:SetChecked(0)
GKRank6Check:Enable()
GKRank7Check:SetChecked(0)
GKRank7Check:Enable()
GKRank8Check:SetChecked(0)
GKRank8Check:Enable()
GKRank9Check:SetChecked(0)
GKRank9Check:Enable()
GKRank10Check:SetChecked(0)
GKRank10Check:Enable()
elseif GKSelfRank==GuildControlGetRankName(6) then
GKRank2Check:SetChecked(1)
GKRank2Check:Disable()
GKRank3Check:SetChecked(1)
GKRank3Check:Disable()
GKRank4Check:SetChecked(1)
GKRank4Check:Disable()
GKRank5Check:SetChecked(1)
GKRank5Check:Disable()
GKRank6Check:SetChecked(1)
GKRank6Check:Disable()
GKRank7Check:SetChecked(0)
GKRank7Check:Enable()
GKRank8Check:SetChecked(0)
GKRank8Check:Enable()
GKRank9Check:SetChecked(0)
GKRank9Check:Enable()
GKRank10Check:SetChecked(0)
GKRank10Check:Enable()
elseif GKSelfRank==GuildControlGetRankName(7) then
GKRank2Check:SetChecked(1)
GKRank2Check:Disable()
GKRank3Check:SetChecked(1)
GKRank3Check:Disable()
GKRank4Check:SetChecked(1)
GKRank4Check:Disable()
GKRank5Check:SetChecked(1)
GKRank5Check:Disable()
GKRank6Check:SetChecked(1)
GKRank6Check:Disable()
GKRank7Check:SetChecked(1)
GKRank7Check:Disable()
GKRank8Check:SetChecked(0)
GKRank8Check:Enable()
GKRank9Check:SetChecked(0)
GKRank9Check:Enable()
GKRank10Check:SetChecked(0)
GKRank10Check:Enable()
elseif GKSelfRank==GuildControlGetRankName(8) then
GKRank2Check:SetChecked(1)
GKRank2Check:Disable()
GKRank3Check:SetChecked(1)
GKRank3Check:Disable()
GKRank4Check:SetChecked(1)
GKRank4Check:Disable()
GKRank5Check:SetChecked(1)
GKRank5Check:Disable()
GKRank6Check:SetChecked(1)
GKRank6Check:Disable()
GKRank7Check:SetChecked(1)
GKRank7Check:Disable()
GKRank8Check:SetChecked(1)
GKRank8Check:Disable()
GKRank9Check:SetChecked(0)
GKRank9Check:Enable()
GKRank10Check:SetChecked(0)
GKRank10Check:Enable()
elseif GKSelfRank==GuildControlGetRankName(9) then
GKRank2Check:SetChecked(1)
GKRank2Check:Disable()
GKRank3Check:SetChecked(1)
GKRank3Check:Disable()
GKRank4Check:SetChecked(1)
GKRank4Check:Disable()
GKRank5Check:SetChecked(1)
GKRank5Check:Disable()
GKRank6Check:SetChecked(1)
GKRank6Check:Disable()
GKRank7Check:SetChecked(1)
GKRank7Check:Disable()
GKRank8Check:SetChecked(1)
GKRank8Check:Disable()
GKRank9Check:SetChecked(1)
GKRank9Check:Disable()
GKRank10Check:SetChecked(0)
GKRank10Check:Enable()
elseif GKSelfRank==GuildControlGetRankName(10) then
GKRank2Check:SetChecked(1)
GKRank2Check:Disable()
GKRank3Check:SetChecked(1)
GKRank3Check:Disable()
GKRank4Check:SetChecked(1)
GKRank4Check:Disable()
GKRank5Check:SetChecked(1)
GKRank5Check:Disable()
GKRank6Check:SetChecked(1)
GKRank6Check:Disable()
GKRank7Check:SetChecked(1)
GKRank7Check:Disable()
GKRank8Check:SetChecked(1)
GKRank8Check:Disable()
GKRank9Check:SetChecked(1)
GKRank9Check:Disable()
GKRank10Check:SetChecked(1)
GKRank10Check:Disable()
else
print('Guild Kicker is still loading permissions! Wait a few seconds then try agian!')
GuildKicker:Hide()
end
end

--UI Attention Functions--
function GKDualKick()
if GKLevelCheck:GetChecked()==1 and GKInactiveCheck:GetChecked()==1 then
print('ATTENTION! You have selected multiple kick criteria. If a member does NOT meet ALL kick criteria, they will NOT be kicked.')
end
end

function GKAltClick()
if GKAltCheck:GetChecked()==1 then
print("ATTENTION! You have selected to exempt alts from being kicked. This only works if the word 'alt' (Case does not matter) appears in either a member's Public Note or Officer Note. (e.g. <Yottabyte's Alt> will be exempt. <Yottabyte's DK> will NOT be exempt.)")
end
end

function GKDualExemptAlt()
if GKAltCheck:GetChecked()==1 and (GKRank2Check:GetChecked()==1 or GKRank3Check:GetChecked()==1 or GKRank4Check:GetChecked()==1 or GKRank5Check:GetChecked()==1 or GKRank6Check:GetChecked()==1 or GKRank7Check:GetChecked()==1 or GKRank8Check:GetChecked()==1 or GKRank9Check:GetChecked()==1 or GKRank10Check:GetChecked()==1) then
print('ATTENTION! You have selected multiple exemption criteria. If a member meets ANY exemption criteria, they will NOT be kicked.')
end
end

function GKDualExemptRank2()
if GKAltCheck:GetChecked()==1 and (GKRank2Check:GetChecked()==1 or GKRank2Check:IsEnabled()~=1) and (GKRank3Check:GetChecked()~=1 or GKRank3Check:IsEnabled()~=1) and (GKRank4Check:GetChecked()~=1  or GKRank4Check:IsEnabled()~=1) and (GKRank5Check:GetChecked()~=1 or GKRank5Check:IsEnabled()~=1) and (GKRank6Check:GetChecked()~=1 or GKRank6Check:IsEnabled()~=1) and (GKRank7Check:GetChecked()~=1 or GKRank7Check:IsEnabled()~=1) and (GKRank8Check:GetChecked()~=1 or GKRank8Check:IsEnabled()~=1) and (GKRank9Check:GetChecked()~=1 or GKRank9Check:IsEnabled()~=1) and (GKRank10Check:GetChecked()~=1 or GKRank10Check:IsEnabled()~=1) then
print('ATTENTION! You have selected multiple exemption criteria. If a member meets ANY exemption criteria, they will NOT be kicked.')
end
end

function GKDualExemptRank3()
if GKAltCheck:GetChecked()==1 and (GKRank2Check:GetChecked()~=1 or GKRank2Check:IsEnabled()~=1) and (GKRank3Check:GetChecked()==1 or GKRank3Check:IsEnabled()~=1) and (GKRank4Check:GetChecked()~=1  or GKRank4Check:IsEnabled()~=1) and (GKRank5Check:GetChecked()~=1 or GKRank5Check:IsEnabled()~=1) and (GKRank6Check:GetChecked()~=1 or GKRank6Check:IsEnabled()~=1) and (GKRank7Check:GetChecked()~=1 or GKRank7Check:IsEnabled()~=1) and (GKRank8Check:GetChecked()~=1 or GKRank8Check:IsEnabled()~=1) and (GKRank9Check:GetChecked()~=1 or GKRank9Check:IsEnabled()~=1) and (GKRank10Check:GetChecked()~=1 or GKRank10Check:IsEnabled()~=1) then
print('ATTENTION! You have selected multiple exemption criteria. If a member meets ANY exemption criteria, they will NOT be kicked.')
end
end

function GKDualExemptRank4()
if GKAltCheck:GetChecked()==1 and (GKRank2Check:GetChecked()~=1 or GKRank2Check:IsEnabled()~=1) and (GKRank3Check:GetChecked()~=1 or GKRank3Check:IsEnabled()~=1) and (GKRank4Check:GetChecked()==1  or GKRank4Check:IsEnabled()~=1) and (GKRank5Check:GetChecked()~=1 or GKRank5Check:IsEnabled()~=1) and (GKRank6Check:GetChecked()~=1 or GKRank6Check:IsEnabled()~=1) and (GKRank7Check:GetChecked()~=1 or GKRank7Check:IsEnabled()~=1) and (GKRank8Check:GetChecked()~=1 or GKRank8Check:IsEnabled()~=1) and (GKRank9Check:GetChecked()~=1 or GKRank9Check:IsEnabled()~=1) and (GKRank10Check:GetChecked()~=1 or GKRank10Check:IsEnabled()~=1) then
print('ATTENTION! You have selected multiple exemption criteria. If a member meets ANY exemption criteria, they will NOT be kicked.')
end
end

function GKDualExemptRank5()
if GKAltCheck:GetChecked()==1 and (GKRank2Check:GetChecked()~=1 or GKRank2Check:IsEnabled()~=1) and (GKRank3Check:GetChecked()~=1 or GKRank3Check:IsEnabled()~=1) and (GKRank4Check:GetChecked()~=1  or GKRank4Check:IsEnabled()~=1) and (GKRank5Check:GetChecked()==1 or GKRank5Check:IsEnabled()~=1) and (GKRank6Check:GetChecked()~=1 or GKRank6Check:IsEnabled()~=1) and (GKRank7Check:GetChecked()~=1 or GKRank7Check:IsEnabled()~=1) and (GKRank8Check:GetChecked()~=1 or GKRank8Check:IsEnabled()~=1) and (GKRank9Check:GetChecked()~=1 or GKRank9Check:IsEnabled()~=1) and (GKRank10Check:GetChecked()~=1 or GKRank10Check:IsEnabled()~=1) then
print('ATTENTION! You have selected multiple exemption criteria. If a member meets ANY exemption criteria, they will NOT be kicked.')
end
end

function GKDualExemptRank6()
if GKAltCheck:GetChecked()==1 and (GKRank2Check:GetChecked()~=1 or GKRank2Check:IsEnabled()~=1) and (GKRank3Check:GetChecked()~=1 or GKRank3Check:IsEnabled()~=1) and (GKRank4Check:GetChecked()~=1  or GKRank4Check:IsEnabled()~=1) and (GKRank5Check:GetChecked()~=1 or GKRank5Check:IsEnabled()~=1) and (GKRank6Check:GetChecked()==1 or GKRank6Check:IsEnabled()~=1) and (GKRank7Check:GetChecked()~=1 or GKRank7Check:IsEnabled()~=1) and (GKRank8Check:GetChecked()~=1 or GKRank8Check:IsEnabled()~=1) and (GKRank9Check:GetChecked()~=1 or GKRank9Check:IsEnabled()~=1) and (GKRank10Check:GetChecked()~=1 or GKRank10Check:IsEnabled()~=1) then
print('ATTENTION! You have selected multiple exemption criteria. If a member meets ANY exemption criteria, they will NOT be kicked.')
end
end

function GKDualExemptRank7()
if GKAltCheck:GetChecked()==1 and (GKRank2Check:GetChecked()~=1 or GKRank2Check:IsEnabled()~=1) and (GKRank3Check:GetChecked()~=1 or GKRank3Check:IsEnabled()~=1) and (GKRank4Check:GetChecked()~=1  or GKRank4Check:IsEnabled()~=1) and (GKRank5Check:GetChecked()~=1 or GKRank5Check:IsEnabled()~=1) and (GKRank6Check:GetChecked()~=1 or GKRank6Check:IsEnabled()~=1) and (GKRank7Check:GetChecked()==1 or GKRank7Check:IsEnabled()~=1) and (GKRank8Check:GetChecked()~=1 or GKRank8Check:IsEnabled()~=1) and (GKRank9Check:GetChecked()~=1 or GKRank9Check:IsEnabled()~=1) and (GKRank10Check:GetChecked()~=1 or GKRank10Check:IsEnabled()~=1) then
print('ATTENTION! You have selected multiple exemption criteria. If a member meets ANY exemption criteria, they will NOT be kicked.')
end
end

function GKDualExemptRank8()
if GKAltCheck:GetChecked()==1 and (GKRank2Check:GetChecked()~=1 or GKRank2Check:IsEnabled()~=1) and (GKRank3Check:GetChecked()~=1 or GKRank3Check:IsEnabled()~=1) and (GKRank4Check:GetChecked()~=1  or GKRank4Check:IsEnabled()~=1) and (GKRank5Check:GetChecked()~=1 or GKRank5Check:IsEnabled()~=1) and (GKRank6Check:GetChecked()~=1 or GKRank6Check:IsEnabled()~=1) and (GKRank7Check:GetChecked()~=1 or GKRank7Check:IsEnabled()~=1) and (GKRank8Check:GetChecked()==1 or GKRank8Check:IsEnabled()~=1) and (GKRank9Check:GetChecked()~=1 or GKRank9Check:IsEnabled()~=1) and (GKRank10Check:GetChecked()~=1 or GKRank10Check:IsEnabled()~=1) then
print('ATTENTION! You have selected multiple exemption criteria. If a member meets ANY exemption criteria, they will NOT be kicked.')
end
end

function GKDualExemptRank9()
if GKAltCheck:GetChecked()==1 and (GKRank2Check:GetChecked()~=1 or GKRank2Check:IsEnabled()~=1) and (GKRank3Check:GetChecked()~=1 or GKRank3Check:IsEnabled()~=1) and (GKRank4Check:GetChecked()~=1  or GKRank4Check:IsEnabled()~=1) and (GKRank5Check:GetChecked()~=1 or GKRank5Check:IsEnabled()~=1) and (GKRank6Check:GetChecked()~=1 or GKRank6Check:IsEnabled()~=1) and (GKRank7Check:GetChecked()~=1 or GKRank7Check:IsEnabled()~=1) and (GKRank8Check:GetChecked()~=1 or GKRank8Check:IsEnabled()~=1) and (GKRank9Check:GetChecked()==1 or GKRank9Check:IsEnabled()~=1) and (GKRank10Check:GetChecked()~=1 or GKRank10Check:IsEnabled()~=1) then
print('ATTENTION! You have selected multiple exemption criteria. If a member meets ANY exemption criteria, they will NOT be kicked.')
end
end

function GKDualExemptRank10()
if GKAltCheck:GetChecked()==1 and (GKRank2Check:GetChecked()~=1 or GKRank2Check:IsEnabled()~=1) and (GKRank3Check:GetChecked()~=1 or GKRank3Check:IsEnabled()~=1) and (GKRank4Check:GetChecked()~=1  or GKRank4Check:IsEnabled()~=1) and (GKRank5Check:GetChecked()~=1 or GKRank5Check:IsEnabled()~=1) and (GKRank6Check:GetChecked()~=1 or GKRank6Check:IsEnabled()~=1) and (GKRank7Check:GetChecked()~=1 or GKRank7Check:IsEnabled()~=1) and (GKRank8Check:GetChecked()~=1 or GKRank8Check:IsEnabled()~=1) and (GKRank9Check:GetChecked()~=1 or GKRank9Check:IsEnabled()~=1) and (GKRank10Check:GetChecked()==1 or GKRank10Check:IsEnabled()~=1) then
print('ATTENTION! You have selected multiple exemption criteria. If a member meets ANY exemption criteria, they will NOT be kicked.')
end
end

--Run Functions--
function GKRun()
GKERROR=0
GKSettingsApply()
GKFinalTableGen()
end

function GKSettingsApply()

if GKInactiveCheck:GetChecked()==1 then
if GKInactiveEditBox:GetNumber()>=1 and GKInactiveEditBox:GetNumber()<=365 then
GKInactivityCalc()
else
GKERROR=1
print('ERROR! You must enter a value from 1-365!')
end
end

if GKLevelCheck:GetChecked()==1 then
if GKLowLevelEditBox:GetNumber()>=1 and GKLowLevelEditBox:GetNumber()<=85 then
GKLevelCalc()
else
GKERROR=1
print('ERROR! You must enter a level value from 1-85!')
end
end

if GKAltCheck:GetChecked()==1 then
GKAltExemptTable()
end

if (GuildControlGetNumRanks()==10 and GKRank10Check:GetChecked()==1 and GKRank9Check:GetChecked()==1 and GKRank8Check:GetChecked()==1 and GKRank7Check:GetChecked()==1 and GKRank6Check:GetChecked()==1 and GKRank5Check:GetChecked()==1 and GKRank4Check:GetChecked()==1 and GKRank3Check:GetChecked()==1 and GKRank2Check:GetChecked()==1) or (GuildControlGetNumRanks()==9 and GKRank9Check:GetChecked()==1 and GKRank8Check:GetChecked()==1 and GKRank7Check:GetChecked()==1 and GKRank6Check:GetChecked()==1 and GKRank5Check:GetChecked()==1 and GKRank4Check:GetChecked()==1 and GKRank3Check:GetChecked()==1 and GKRank2Check:GetChecked()==1) or (GuildControlGetNumRanks()==8 and GKRank8Check:GetChecked()==1 and GKRank7Check:GetChecked()==1 and GKRank6Check:GetChecked()==1 and GKRank5Check:GetChecked()==1 and GKRank4Check:GetChecked()==1 and GKRank3Check:GetChecked()==1 and GKRank2Check:GetChecked()==1) or (GuildControlGetNumRanks()==7 and GKRank7Check:GetChecked()==1 and GKRank6Check:GetChecked()==1 and GKRank5Check:GetChecked()==1 and GKRank4Check:GetChecked()==1 and GKRank3Check:GetChecked()==1 and GKRank2Check:GetChecked()==1) or (GuildControlGetNumRanks()==6 and GKRank6Check:GetChecked()==1 and GKRank5Check:GetChecked()==1 and GKRank4Check:GetChecked()==1 and GKRank3Check:GetChecked()==1 and GKRank2Check:GetChecked()==1) or (GuildControlGetNumRanks()==5 and GKRank5Check:GetChecked()==1 and GKRank4Check:GetChecked()==1 and GKRank3Check:GetChecked()==1 and GKRank2Check:GetChecked()==1) or (GuildControlGetNumRanks()==4 and GKRank4Check:GetChecked()==1 and GKRank3Check:GetChecked()==1 and GKRank2Check:GetChecked()==1) or (GuildControlGetNumRanks()==3 and GKRank3Check:GetChecked()==1 and GKRank2Check:GetChecked()==1) or (GuildControlGetNumRanks()==2 and GKRank2Check:GetChecked()==1) or (GuildControlGetNumRanks()==1) then
GKERROR=1
print('ERROR! All Ranks Are Exempt! This is because you do not have permission to kick members or you have selected all ranks! Check your settings & permissons then try agian!')
else
GKRankExemptTable()
end

if GKLevelCheck:GetChecked()~=1 and GKInactiveCheck:GetChecked()~=1 then
GKERROR=1
print('ERROR! You must select a Kick Criteria!')
end
end

function GKFinalTableGen()
if GKERROR~=1 then
GKKickt = {}
if GKAltCheck:GetChecked()==1 and GKLevelCheck:GetChecked()==1 and GKInactiveCheck:GetChecked()==1 then
for i=1,GetNumGuildMembers(true) do local name,_,_,level = GetGuildRosterInfo(i);
if tContains(GKAltt, i)~=1 and tContains(GKRankt, i)~=1 and tContains(GKInactivet, i)==1 and tContains(GKlvlt, i)==1 then 
tinsert(GKKickt, name);
end
end
elseif GKAltCheck:GetChecked()==1 and GKLevelCheck:GetChecked()~=1 and GKInactiveCheck:GetChecked()==1 then
for i=1,GetNumGuildMembers(true) do local name,_,_,level = GetGuildRosterInfo(i);
if tContains(GKAltt, i)~=1 and tContains(GKRankt, i)~=1 and tContains(GKInactivet, i)==1 then 
tinsert(GKKickt, name);
end
end
elseif GKAltCheck:GetChecked()==1 and GKLevelCheck:GetChecked()==1 and GKInactiveCheck:GetChecked()~=1 then
for i=1,GetNumGuildMembers(true) do local name,_,_,level = GetGuildRosterInfo(i);
if tContains(GKAltt, i)~=1 and tContains(GKRankt, i)~=1 and tContains(GKlvlt, i)==1 then 
tinsert(GKKickt, name);
end
end
elseif GKAltCheck:GetChecked()~=1 and GKLevelCheck:GetChecked()==1 and GKInactiveCheck:GetChecked()==1 then
for i=1,GetNumGuildMembers(true) do local name,_,_,level = GetGuildRosterInfo(i);
if tContains(GKRankt, i)~=1 and tContains(GKInactivet, i)==1 and tContains(GKlvlt, i)==1 then 
tinsert(GKKickt, name);
end
end
elseif GKAltCheck:GetChecked()~=1 and GKLevelCheck:GetChecked()~=1 and GKInactiveCheck:GetChecked()==1 then
for i=1,GetNumGuildMembers(true) do local name,_,_,level = GetGuildRosterInfo(i);
if tContains(GKRankt, i)~=1 and tContains(GKInactivet, i)==1 then 
tinsert(GKKickt, name);
end
end
elseif GKAltCheck:GetChecked()~=1 and GKLevelCheck:GetChecked()==1 and GKInactiveCheck:GetChecked()~=1 then
for i=1,GetNumGuildMembers(true) do local name,_,_,level = GetGuildRosterInfo(i);
if tContains(GKRankt, i)~=1 and tContains(GKlvlt, i)==1 then 
tinsert(GKKickt, name);
end
end
else
end
end
if GKERROR~=1 then
table.foreach(GKKickt, print)
GKDialogSet()
GKConfirmDialog:Show()
end
end

--Inactivity Functions--
function GKInactivityCalc()
if GKInactiveEditBox:GetNumber()<=365 and GKInactiveEditBox:GetNumber()>=360 then
GKy=1
GKm=0
GKd=0
GKParseTime()
GKByInactivityTable()
elseif GKInactiveEditBox:GetNumber()<360 and GKInactiveEditBox:GetNumber()>=330 then
GKy=0
GKm=11
GKd=GKInactiveEditBox:GetNumber()-(30*11)
GKParseTime()
GKByInactivityTable()
elseif GKInactiveEditBox:GetNumber()<330 and GKInactiveEditBox:GetNumber()>=300 then
GKy=0
GKm=10
GKd=GKInactiveEditBox:GetNumber()-(30*10)
GKParseTime()
GKByInactivityTable()
elseif GKInactiveEditBox:GetNumber()<300 and GKInactiveEditBox:GetNumber()>=270 then
GKy=0
GKm=9
GKd=GKInactiveEditBox:GetNumber()-(30*9)
GKParseTime()
GKByInactivityTable()
elseif GKInactiveEditBox:GetNumber()<270 and GKInactiveEditBox:GetNumber()>=240 then
GKy=0
GKm=8
GKd=GKInactiveEditBox:GetNumber()-(30*8)
GKParseTime()
GKByInactivityTable()
elseif GKInactiveEditBox:GetNumber()<240 and GKInactiveEditBox:GetNumber()>=210 then
GKy=0
GKm=7
GKd=GKInactiveEditBox:GetNumber()-(30*7)
GKParseTime()
GKByInactivityTable()
elseif GKInactiveEditBox:GetNumber()<210 and GKInactiveEditBox:GetNumber()>=180 then
GKy=0
GKm=6
GKd=GKInactiveEditBox:GetNumber()-(30*6)
GKParseTime()
GKByInactivityTable()
elseif GKInactiveEditBox:GetNumber()<180 and GKInactiveEditBox:GetNumber()>=150 then
GKy=0
GKm=5
GKd=GKInactiveEditBox:GetNumber()-(30*5)
GKParseTime()
GKByInactivityTable()
elseif GKInactiveEditBox:GetNumber()<150 and GKInactiveEditBox:GetNumber()>=120 then
GKy=0
GKm=4
GKd=GKInactiveEditBox:GetNumber()-(30*4)
GKParseTime()
GKByInactivityTable()
elseif GKInactiveEditBox:GetNumber()<120 and GKInactiveEditBox:GetNumber()>=90 then
GKy=0
GKm=3
GKd=GKInactiveEditBox:GetNumber()-(30*3)
GKParseTime()
GKByInactivityTable()
elseif GKInactiveEditBox:GetNumber()<90 and GKInactiveEditBox:GetNumber()>=60 then
GKy=0
GKm=2
GKd=GKInactiveEditBox:GetNumber()-(30*2)
GKParseTime()
GKByInactivityTable()
elseif GKInactiveEditBox:GetNumber()<60 and GKInactiveEditBox:GetNumber()>=30 then
GKy=0
GKm=1
GKd=GKInactiveEditBox:GetNumber()-30
GKParseTime()
GKByInactivityTable()
elseif GKInactiveEditBox:GetNumber()<30 and GKInactiveEditBox:GetNumber()>=1 then
GKy=0
GKm=0
GKd=GKInactiveEditBox:GetNumber()
GKParseTime()
GKByInactivityTable()
else
end
end

function GKParseTime()
if GKm>0 and GKd==0 then
GKm1=GKm
GKd1=GKd
GKm2=GKm
GKd2=GKd
elseif GKm>0 and GKd>0 then
GKm1=GKm
GKd1=GKd
GKm2=GKm+1
GKd2=0
elseif GKm==0 and GKd>0 then
GKm1=GKm
GKd1=GKd
GKm2=GKm+1
GKd2=0
elseif GKy==1 and GKm==0 and GKd==0 then
GKm1=99
GKd1=99
GKm2=99
GKd2=99
else
end
end

--Level Functions--
function GKLevelCalc()
GKlvl=GKLowLevelEditBox:GetNumber()
GKByLevelTable()
end

--Kick Table Functions--
function GKByLevelTable()
GKlvlt = {}
for i=1,GetNumGuildMembers(true) do local name,_,_,level = GetGuildRosterInfo(i);
if GKLevelCheck:GetChecked()==1 and level<=GKlvl then 
tinsert(GKlvlt, i);
end
end
end

function GKByInactivityTable()
GKInactivet = {}
for i=1,GetNumGuildMembers() do local y,m,d=GetGuildRosterLastOnline(i)
if y then
if GKInactiveCheck:GetChecked()==1 and ((y>=0 and m==GKm1 and d>=GKd1) or (y>=0 and m>=GKm2 and d>=GKd2) or (y>=1 and m>=0 and d>=0)) then 
tinsert(GKInactivet, i)
end
end
end
end

--Exemption Table Functions--
function GKAltExemptTable()
GKAltt = {}
for i=1,GetNumGuildMembers(true) do local name,_,_,_,_,_,note,officer = GetGuildRosterInfo(i);
if GKAltCheck:GetChecked()==1 and (string.find(note, "Alt")~=nil or string.find(note, "AlT")~=nil or string.find(note, "ALt")~=nil or string.find(note, "ALT")~=nil or string.find(note, "aLt")~=nil or string.find(note, "aLT")~=nil or string.find(note, "alt")~=nil or string.find(note, "alT")~=nil or string.find(officer, "Alt")~=nil or string.find(officer, "AlT")~=nil or string.find(officer, "ALt")~=nil or string.find(officer, "ALT")~=nil or string.find(officer, "aLt")~=nil or string.find(officer, "aLT")~=nil or string.find(officer, "alt")~=nil or string.find(officer, "alT")~=nil) then 
tinsert(GKAltt, i);
end
end
end

function GKRankExemptTable()
GKRankt = {}
for i=1,GetNumGuildMembers(true) do local name,rank,rankindex = GetGuildRosterInfo(i);
if rank==GuildControlGetRankName(1) or (GKRank2Check:GetChecked()==1 and rank==GuildControlGetRankName(2)) or (GKRank3Check:GetChecked()==1 and rank==GuildControlGetRankName(3)) or (GKRank4Check:GetChecked()==1 and rank==GuildControlGetRankName(4)) or (GKRank5Check:GetChecked()==1 and rank==GuildControlGetRankName(5)) or (GKRank6Check:GetChecked()==1 and rank==GuildControlGetRankName(6)) or (GKRank7Check:GetChecked()==1 and rank==GuildControlGetRankName(7)) or (GKRank8Check:GetChecked()==1 and rank==GuildControlGetRankName(8)) or (GKRank9Check:GetChecked()==1 and rank==GuildControlGetRankName(9)) or (GKRank10Check:GetChecked()==1 and rank==GuildControlGetRankName(10)) then 
tinsert(GKRankt, i);
end
end
end

--Confirmation Functions--
function GKDialogSet()
GKConfirmNumFont:SetText(table.getn(GKKickt))
GKConfirmFont:SetText("members will be kicked. Are you sure you want to kick them? (Names are listed below)")
end

function GKKickConfirmed()
PlaySoundFile("Sound\\Creature\\LichKing\\LH_LichKing_LightsHopeEvent06.wav")
for k,v in pairs(GKKickt) do GuildUninvite(v) end
print(table.getn(GKKickt),'members were kicked from the guild!')
GKConfirmDialog:Hide()
end

function GKKickCanceled()
GKConfirmDialog:Hide()
GKKickt = {}
print('Purge has been canceled!')
end